import sys
from bs4 import BeautifulSoup

infile = sys.argv[1]


def parse_table_with_thead_tbody(html_table):
    soup = BeautifulSoup(html_table, 'html.parser')
    table = soup.find('table')
    
    # 初始化表头和表格数据
    headers = []
    table_data = []
    
    # 解析表头
    thead = table.find('thead')
    if thead:
        for th in thead.find_all('th'):
            headers.append(th.get_text(strip=True))
    
    # 解析表格数据
    tbody = table.find('tbody')
    if tbody:
        for row in tbody.find_all('tr'):
            row_data = []
            for cell in row.find_all('td'):
                row_data.append(cell.get_text(strip=True))
            table_data.append(row_data)
    
    return headers, table_data


with open(infile) as f:
    content = f.read().strip()

headers, table_data = parse_table_with_thead_tbody(content)
print("\t".join(headers))
for row in table_data:
    print("\t".join(row))
